package j01zhengze;

public class J1 {
    public static void main(String[] args) {
        // 检测abc是否由abc组成
        //正则表达式，以字符串形式体现
        boolean isOk = "abc".matches("abc");
        System.out.println("isOk = " + isOk);

        //aWc  aXc   a c   aKc
        //.通配符，什么符号都行
        System.out.println("axc".matches("a.c"));//true
        System.out.println("aKc".matches("a.c"));//true
        System.out.println("aKyc".matches("a.c"));//false
        System.out.println("aK#c".matches("a..c"));//true
        System.out.println("=====");
        System.out.println("abc".matches("a[xyz]c]"));//false
        System.out.println("axc".matches("a[xyz]c"));//true
        System.out.println("axyc".matches("a[xyz]c"));//false
        System.out.println("a3c".matches("a[0123456789]c"));//true
        System.out.println("a3c".matches("a[0-9]c"));//true
        System.out.println("_a_".matches("_[a-zA-Z0-9]_"));//true
        System.out.println("_0_".matches("_[a-zA-Z6-9]_"));//false
    }
}

class J2{
    public static void main(String[] args) {
        System.out.println("abc".matches("a(b|xyz|mm|ww)c"));//true
        System.out.println("ammc".matches("a(b|xyz|mm|ww)c"));//true
        System.out.println("ammmc".matches("a(b|xyz|mm|ww)c"));//false
        System.out.println("===");
        //b,3
        System.out.println("abbc".matches("ab{3}c"));//false
        System.out.println("abbbc".matches("ab{3}c"));//true
        System.out.println("abbbbc".matches("ab{3}c"));//false
        System.out.println("abc".matches("ab{3,10}c"));//false
        System.out.println("abbbbbbc".matches("ab{3,10}c"));//true
        //a{10,}
        //a{,10}
        System.out.println(">>>>>>");
        System.out.println("abc".matches("a[^0-9]c"));//true
        System.out.println("a0c".matches("a[^0-9]c"));//false
        /*
        js
        abc    "xyzabc8888"
         */
        System.out.println("<<<<<<<<<<<<<<");
        System.out.println("abc".matches("ab+c"));
        System.out.println("abbc".matches("ab+c"));
        System.out.println("abbbbbbbc".matches("ab+c"));
        System.out.println("ac".matches("ab+c"));//false
        System.out.println("abc".matches("ab?c"));//true
        System.out.println("ac".matches("ab?c"));//true
        System.out.println("amc".matches("ab?c"));//false
    }
}

class J3{
    public static void main(String[] args) {
        System.out.println("abc".matches("a[0-9]c"));//false
        System.out.println("abc".matches("a\\dc"));//false
        System.out.println("a8c".matches("a\\dc"));//true
        System.out.println("a8c".matches("a\\d?c"));//true
        System.out.println("axc".matches("a\\d?c"));//false

        System.out.println("axc".matches("a\\Dc"));//true
        System.out.println("a c".matches("a\\Dc"));//true
    }
}